#include "ConfigManager.h"

ConfigManager g_pConfigManager;

char IniPath[512];

void ConfigManager::UpdateFeatureString()
{
	strcpy(ActiveFeatureString, /*Active Features:\n \n*/XorStr(19, 0xB5, 0xF457C75B, 0xC7558F68, 0xC84DDF5F, 0xDB4DD41C, 0xAF04A900).c_str());
	if (Aimbot)
	{
		if (SilentAim)
		{
			JUNK_CODE;
			strcat(ActiveFeatureString, /*Aimbot (Silent)\n*/XorStr(16, 0x75, 0x349D1E90, 0x1E844FC6, 0x3E85078F, 0x079C4EEC).c_str());
		}
		else
		{
			strcat(ActiveFeatureString, /*Aimbot\n*/XorStr(7, 0x10, 0x51E663EF, 0x63FF0000).c_str());
		}
	}
	JUNK_CODE;
	if (NoSpread)
	{
		strcat(ActiveFeatureString, /*NoSpread\n*/XorStr(9, 0xCE, 0x80229F3B, 0xB82CA923, 0xCC000000).c_str());
	}
	if (NoRecoil)
	{
		strcat(ActiveFeatureString, /*NoRecoil\n*/XorStr(9, 0x4A, 0x04A61AA2, 0x25AA2DAF, 0x48000000).c_str());
	}
	if (Trigger)
	{
		JUNK_CODE;
		if (TriggerHeadshotOnly)
		{
			strcat(ActiveFeatureString, /*Trigger (HS Only)\n*/XorStr(18, 0xBC, 0xE849D35E, 0xDF52C415, 0x9C7BE111, 0xFF41C254, 0x85210000).c_str());
		}
		else
		{
			JUNK_CODE;
			strcat(ActiveFeatureString, /*Trigger\n*/XorStr(8, 0x0D, 0x59FE62ED, 0x6EED758C).c_str());
		}
	}
	if (Esp)
	{
		strcat(ActiveFeatureString, /*Esp\n*/XorStr(4, 0x19, 0x5CEB679C).c_str());
	}
	JUNK_CODE;
	if (NoSky)
	{
		strcat(ActiveFeatureString, /*NoSky\n*/XorStr(6, 0x55, 0x1BBB00B9, 0x28DA0000).c_str());
	}
	if (NoFlash)
	{
		strcat(ActiveFeatureString, /*NoFlash\n*/XorStr(8, 0xDD, 0x93339D36, 0xB82BBF5C).c_str());
	}
	if (NoSmoke)
	{
		strcat(ActiveFeatureString, /*NoSmoke\n*/XorStr(8, 0xB5, 0xFB5BE05F, 0xDE5BCA24).c_str());
	}
	if (NoHands)
	{
		strcat(ActiveFeatureString, /*NoHands\n*/XorStr(8, 0x75, 0x3B9B3B93, 0x1F941CE4).c_str());
	}
	if (Asus)
	{
		strcat(ActiveFeatureString, /*Asus\n*/XorStr(5, 0xF8, 0xB9048306, 0xFE000000).c_str());
	}
	if (AutoPistol)
	{
		JUNK_CODE;
		strcat(ActiveFeatureString, /*AutoPistol\n*/XorStr(11, 0xF6, 0xB700801C, 0xA218831B, 0x8101E600).c_str());
	}
	if (Crosshair)
	{
		strcat(ActiveFeatureString, /*Crosshair\n*/XorStr(10, 0x55, 0x16A63CA1, 0x22B82EA7, 0x3FC60000).c_str());
	}
	JUNK_CODE;
	if (Bhop)
	{
		strcat(ActiveFeatureString, /*Bunnyhop\n*/XorStr(9, 0xBD, 0xFF49D554, 0xC050D846, 0xBF000000).c_str());
	}
	if (RadarHack)
	{
		strcat(ActiveFeatureString, /*RadarHack\n*/XorStr(10, 0x30, 0x62CE4ACC, 0x5EE34BCA, 0x43AD0000).c_str());
	}
}

void ConfigManager::LoadSection( char* Section )
{
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*Aimbot*/XorStr(6, 0xCD, 0x8C25A628, 0xA63C0000).c_str(), &Aimbot);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*SilentAim*/XorStr(9, 0x92, 0xC178FC6A, 0xE079CD62, 0xE7000000).c_str(), &SilentAim);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*NoSpread*/XorStr(8, 0xDC, 0x92348929, 0xAA32B731).c_str(), &NoSpread);
	JUNK_CODE;
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*NoRecoil*/XorStr(8, 0xC3, 0x8D2D9325, 0xDC51D450).c_str(), &NoRecoil);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*Trigger*/XorStr(7, 0x74, 0x20811B96, 0x178A1C00).c_str(), &Trigger);
	JUNK_CODE;
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*TriggerHSOnly*/XorStr(13, 0x34, 0x60C15BD6, 0x57CA5CE5, 0x7FE444C5, 0x51000000).c_str(), &TriggerHeadshotOnly);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*Esp*/XorStr(3, 0xEA, 0xAF1A9800).c_str(), &Esp);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*NoSky*/XorStr(5, 0xBA, 0xF456EB5C, 0xCF000000).c_str(), &NoSky);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*NoFlash*/XorStr(7, 0x7A, 0x34963E9B, 0x17861C00).c_str(), &NoFlash);
	JUNK_CODE;
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*NoSmoke*/XorStr(7, 0xC3, 0x8D2D922D, 0xD055D800).c_str(), &NoSmoke);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*NoHands*/XorStr(7, 0xA1, 0xEF4FD77F, 0xF378E800).c_str(), &NoHands);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*Asus*/XorStr(4, 0x18, 0x59E463E6).c_str(), &Asus);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*AutoPistol*/XorStr(10, 0x0C, 0x4DFE7EE6, 0x58EE75F1, 0x6BEF0000).c_str(), &AutoPistol);
	JUNK_CODE;
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*Crosshair*/XorStr(9, 0x12, 0x51E37FFC, 0x7DE56DE2, 0x78000000).c_str(), &Crosshair);
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*Bhop*/XorStr(4, 0xAD, 0xEF44C45A).c_str(), &Bhop);
	JUNK_CODE;
	SD_Tools::AbstractIni::LoadBool(IniPath, Section, (char*)/*RadarHack*/XorStr(9, 0x40, 0x12DE5ADC, 0x4EF35BDA, 0x53000000).c_str(), &RadarHack);
	UpdateFeatureString();
}

void ConfigManager::ExecuteCurrent()
{
	g_pAimbot.Set(Aimbot);
	g_pAimbot.Silent = SilentAim;
	JUNK_CODE;
	g_pNoSpread.Set(NoSpread);
	g_pNoSpread.SetRecoil(NoRecoil);
	g_pEasyTrigger.Set(Trigger);
	g_pEasyTrigger.SetHeadOnly(TriggerHeadshotOnly);
	g_pESP.Set(Esp);
	JUNK_CODE;
	g_pCheats.SetNoSky(NoSky);
	g_pNoflash.Set(NoFlash);
	g_pNoSmoke.SetActive(NoSmoke);
	JUNK_CODE;
	g_pNoHands.SetActive(NoHands);
	g_pCheats.SetAsus(Asus);
	g_pAutoPistol.Set(AutoPistol);
	JUNK_CODE;
	g_pCrosshair.Set(Crosshair);
	g_pBHop.SetActive(Bhop);
	g_pHudRadar.Set(RadarHack);
}

void ConfigManager::Load()
{
	Aimbot = 0;
	SilentAim = 0;
	NoSpread = 0;
	NoRecoil = 0;
	Trigger = 0;
	TriggerHeadshotOnly = 0;
	JUNK_CODE;
	Esp = 0;
	NoSky = 0;
	NoFlash = 0;
	NoSmoke = 0;
	NoHands = 0;
	JUNK_CODE;
	Asus = 0;
	AutoPistol = 0;
	Crosshair = 0;
	Bhop = 0;
	RadarHack = 0;
	ActiveFeatureString[0] = '\0';
	wchar_t szPath[512];
	JUNK_CODE;
	SD_Tools::GetRealDir(g_pInterfaces.hModuleBase, szPath, 512);
	JUNK_CODE;
	wcstombs(IniPath, szPath, 512);

	strcat(IniPath, /*\\Config.ini*/XorStr(11, 0xB4, 0xE870DD5F, 0xD646C903, 0xC545C300).c_str());

	JUNK_CODE;
	LoadSection((char*)/*Default*/XorStr(7, 0x57, 0x13B333B5, 0x26BE2500).c_str());
	ExecuteCurrent();
}

void ConfigManager::Execute1()
{
	LoadSection((char*)/*Insert*/XorStr(6, 0x27, 0x6EC856C1, 0x51D60000).c_str());
	JUNK_CODE;
	ExecuteCurrent();
}

void ConfigManager::Execute2()
{
	LoadSection((char*)/*Delete*/XorStr(6, 0x05, 0x41E16FE7, 0x75E50000).c_str());
	JUNK_CODE;
	ExecuteCurrent();
}

void ConfigManager::Execute3()
{
	LoadSection((char*)/*Home*/XorStr(4, 0x18, 0x50F87BF0).c_str());
	ExecuteCurrent();
}

void ConfigManager::Execute4()
{
	JUNK_CODE;
	LoadSection((char*)/*End*/XorStr(3, 0x51, 0x14BE2B00).c_str());
	ExecuteCurrent();
}

void ConfigManager::Execute5()
{
	LoadSection((char*)/*PgUp*/XorStr(4, 0x48, 0x18A013B5).c_str());
	ExecuteCurrent();
}

void ConfigManager::Execute6()
{
	LoadSection((char*)/*PgDn*/XorStr(4, 0xAA, 0xFA4EEC49).c_str());
	ExecuteCurrent();
}

char* ConfigManager::GetActiveFeatureString()
{
	return ActiveFeatureString;
}

